{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import tushare as ts\n",
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "conn = ts.get_apis()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Mon Sep  3 09:36:59 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:37:04 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:37:09 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:37:14 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:37:19 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:37:24 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:37:29 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:37:35 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:37:40 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:37:45 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:37:50 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:37:55 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:38:00 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:38:05 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:38:10 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:38:15 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:38:20 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:38:25 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:38:30 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:38:35 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:38:40 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:38:45 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:38:50 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:38:55 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:39:00 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:39:05 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:39:10 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:39:15 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:39:20 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:39:25 2018\n",
      "zz ask 915.1\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:39:30 2018\n",
      "zz ask 915.1\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:39:35 2018\n",
      "zz ask 915.1\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:39:41 2018\n",
      "zz ask 915.1\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:39:46 2018\n",
      "zz ask 915.1\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:39:51 2018\n",
      "zz ask 915.1\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:39:56 2018\n",
      "zz ask 915.1\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:40:01 2018\n",
      "zz ask 915.1\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:40:06 2018\n",
      "zz ask 915.1\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:40:11 2018\n",
      "zz ask 915.1\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:40:16 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:40:21 2018\n",
      "zz ask 915.2\n",
      "zz bid 915.0\n",
      "Mon Sep  3 09:40:26 2018\n",
      "zz ask 915.0\n",
      "zz bid 913.01\n",
      "Mon Sep  3 09:40:31 2018\n",
      "zz ask 915.0\n",
      "zz bid 913.01\n",
      "Mon Sep  3 09:40:36 2018\n",
      "zz ask 915.0\n",
      "zz bid 913.01\n",
      "Mon Sep  3 09:40:41 2018\n",
      "zz ask 915.0\n",
      "zz bid 913.01\n",
      "Mon Sep  3 09:40:46 2018\n",
      "zz ask 915.0\n",
      "zz bid 913.01\n",
      "Mon Sep  3 09:40:51 2018\n",
      "zz ask 913.01\n",
      "zz bid 913.0\n",
      "Mon Sep  3 09:40:56 2018\n",
      "zz ask 913.01\n",
      "zz bid 913.0\n",
      "Mon Sep  3 09:41:01 2018\n",
      "zz ask 913.01\n",
      "zz bid 913.0\n",
      "Mon Sep  3 09:41:06 2018\n",
      "zz ask 913.01\n",
      "zz bid 913.0\n",
      "Mon Sep  3 09:41:11 2018\n",
      "zz ask 913.01\n",
      "zz bid 913.0\n",
      "Mon Sep  3 09:41:16 2018\n",
      "zz ask 913.01\n",
      "zz bid 913.0\n",
      "Mon Sep  3 09:41:21 2018\n",
      "zz ask 913.01\n",
      "zz bid 913.0\n",
      "Mon Sep  3 09:41:26 2018\n",
      "zz ask 913.01\n",
      "zz bid 913.0\n",
      "Mon Sep  3 09:41:31 2018\n",
      "zz ask 913.01\n",
      "zz bid 913.0\n",
      "Mon Sep  3 09:41:36 2018\n",
      "zz ask 913.01\n",
      "zz bid 913.0\n",
      "Mon Sep  3 09:41:42 2018\n",
      "zz ask 913.0\n",
      "zz bid 910.3\n",
      "Mon Sep  3 09:41:47 2018\n",
      "zz ask 913.0\n",
      "zz bid 910.3\n",
      "Mon Sep  3 09:41:52 2018\n",
      "zz ask 913.0\n",
      "zz bid 910.3\n",
      "Mon Sep  3 09:41:57 2018\n",
      "zz ask 913.0\n",
      "zz bid 910.3\n",
      "Mon Sep  3 09:42:02 2018\n",
      "zz ask 913.0\n",
      "zz bid 910.3\n",
      "Mon Sep  3 09:42:07 2018\n",
      "zz ask 913.0\n",
      "zz bid 910.3\n",
      "Mon Sep  3 09:42:12 2018\n",
      "zz ask 913.0\n",
      "zz bid 910.31\n",
      "Mon Sep  3 09:42:17 2018\n",
      "zz ask 913.0\n",
      "zz bid 910.31\n",
      "Mon Sep  3 09:42:22 2018\n",
      "zz ask 910.3\n",
      "zz bid 910.01\n",
      "Mon Sep  3 09:42:27 2018\n",
      "zz ask 910.3\n",
      "zz bid 910.01\n",
      "Mon Sep  3 09:42:32 2018\n",
      "zz ask 910.3\n",
      "zz bid 910.01\n",
      "Mon Sep  3 09:42:37 2018\n",
      "zz ask 912.99\n",
      "zz bid 910.3\n",
      "Mon Sep  3 09:42:42 2018\n",
      "zz ask 912.99\n",
      "zz bid 910.3\n",
      "Mon Sep  3 09:42:47 2018\n",
      "zz ask 913.0\n",
      "zz bid 910.3\n",
      "Mon Sep  3 09:42:52 2018\n",
      "zz ask 912.94\n",
      "zz bid 910.6\n",
      "Mon Sep  3 09:42:57 2018\n",
      "zz ask 912.94\n",
      "zz bid 910.6\n",
      "Mon Sep  3 09:43:02 2018\n",
      "zz ask 912.94\n",
      "zz bid 910.6\n",
      "Mon Sep  3 09:43:07 2018\n",
      "zz ask 912.94\n",
      "zz bid 910.6\n",
      "Mon Sep  3 09:43:12 2018\n",
      "zz ask 912.94\n",
      "zz bid 910.6\n",
      "Mon Sep  3 09:43:17 2018\n",
      "zz ask 912.94\n",
      "zz bid 910.6\n",
      "Mon Sep  3 09:43:22 2018\n",
      "zz ask 912.94\n",
      "zz bid 910.6\n",
      "Mon Sep  3 09:43:27 2018\n",
      "zz ask 912.94\n",
      "zz bid 910.6\n",
      "Mon Sep  3 09:43:32 2018\n",
      "zz ask 912.94\n",
      "zz bid 910.6\n",
      "Mon Sep  3 09:43:37 2018\n",
      "zz ask 912.94\n",
      "zz bid 910.6\n",
      "Mon Sep  3 09:43:42 2018\n",
      "zz ask 912.94\n",
      "zz bid 910.61\n",
      "Mon Sep  3 09:43:48 2018\n",
      "zz ask 912.94\n",
      "zz bid 910.61\n",
      "Mon Sep  3 09:43:53 2018\n",
      "zz ask 912.94\n",
      "zz bid 910.61\n",
      "Mon Sep  3 09:43:58 2018\n",
      "zz ask 912.94\n",
      "zz bid 910.61\n",
      "Mon Sep  3 09:44:03 2018\n",
      "zz ask 912.94\n",
      "zz bid 910.62\n",
      "Mon Sep  3 09:44:08 2018\n",
      "zz ask 912.94\n",
      "zz bid 910.62\n",
      "Mon Sep  3 09:44:13 2018\n",
      "zz ask 910.62\n",
      "zz bid 910.61\n",
      "Mon Sep  3 09:44:18 2018\n",
      "zz ask 910.62\n",
      "zz bid 910.61\n",
      "Mon Sep  3 09:44:23 2018\n",
      "zz ask 910.62\n",
      "zz bid 910.61\n",
      "Mon Sep  3 09:44:28 2018\n",
      "zz ask 910.62\n",
      "zz bid 910.61\n",
      "Mon Sep  3 09:44:33 2018\n",
      "zz ask 910.62\n",
      "zz bid 910.61\n",
      "Mon Sep  3 09:44:38 2018\n",
      "zz ask 910.62\n",
      "zz bid 910.61\n",
      "Mon Sep  3 09:44:43 2018\n",
      "zz ask 912.93\n",
      "zz bid 910.61\n",
      "Mon Sep  3 09:44:48 2018\n",
      "zz ask 912.93\n",
      "zz bid 910.62\n",
      "Mon Sep  3 09:44:53 2018\n",
      "zz ask 912.93\n",
      "zz bid 910.61\n",
      "Mon Sep  3 09:44:58 2018\n",
      "zz ask 912.94\n",
      "zz bid 910.61\n",
      "Mon Sep  3 09:45:03 2018\n",
      "zz ask 912.94\n",
      "zz bid 910.62\n",
      "Mon Sep  3 09:45:08 2018\n",
      "zz ask 912.94\n",
      "zz bid 910.62\n",
      "Mon Sep  3 09:45:13 2018\n",
      "zz ask 912.94\n",
      "zz bid 910.66\n",
      "Mon Sep  3 09:45:18 2018\n",
      "zz ask 912.94\n",
      "zz bid 910.66\n"
     ]
    }
   ],
   "source": [
    "for i in range(100):\n",
    "    zz_df = ts.quotes('123014',conn)\n",
    "#     zg_df = ts.quotes('300568',conn)\n",
    "    print(time.ctime())\n",
    "    print('zz ask',zz_df['ask1'].values[0])\n",
    "    print('zz bid',zz_df['bid1'].values[0])\n",
    "#     print('zg bid',zg_df['bid1'].values[0])\n",
    "#     print('zg bid',zg_df['bid1'].values[0])\n",
    "    time.sleep(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "df.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "ts.close_apis(conn)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    9.29\n",
       "Name: bid1, dtype: float64"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 使用另外一个接口"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
